<template>
	<div class="body">
		<!-- 添加教师 -->
		<!-- <div class="header">
			<div>
				<img @click="returnGo" src="../../assets/homeimg/滑动左.png" />
				<span>添加二维码</span>
			</div>
		</div> -->
		<div class="tianjia">
			<img :src="code.teacher_image" alt class="code" />
		</div>
		<div class="button" @click="save">保存二维码</div>
		<van-loading v-if="show" size="40px" vertical>保存中...</van-loading>
	</div>
</template>

<script>
	import mineApi from "@/api/mine";
	import { Loading } from 'vant';
	export default {
		data() {
			return {
				code: "",
				id: '',
				show: false
			};
		},
		components: {},
		created() {
			this.id = this.$route.query.id;
			this.getteacherImage();
		},
		methods: {
			returnGo() {
				this.$router.go(-1);
			},
			getteacherImage() {
				this.$http.post('/api/curriculum/teacherImage',{id: this.id}).then(res => {
					console.log(res)
					this.code = res.data
				})
				// mineApi.teacherImage({
				// 	id: this.id
				// }).then(res => {
				// 	console.log(res);
				// 	this.code = res.data.tacher_image
				// })
			},
			save(){
				// this.show = true;
				let data = {
					url: this.code.teacher_image
				}
				window.h5_android && window.h5_android.saveImg(JSON.stringify(data));
				window.webkit.messageHandlers.saveImage_js.postMessage([this.code.teacher_image]);
			}
		}
	};
</script>

<style scoped lang="scss">
	.body {
		color: #333333;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: url("../../assets/homeimg/addteacher.png");
		background-size: 100% 100%;
	}

	.header {
		// font-weight: bold;
		width: 100%;
		text-align: center;
		height: 2.75rem;
		line-height: 2.75rem;
		padding-top: 1.25rem;
		position: relative;
		border-bottom: 1px solid #dcdcdc;
		color: #333333;
		font-size: 1.25rem;

		img {
			width: 0.625rem;
			height: 1.125rem;
			position: absolute;
			left: 1rem;
			bottom: 0.75rem;
		}
	}
// 在scss文件中
	@supports(bottom:constant(safe-area-inset-top)) {

		// 如果存在底部安全区域
		.header {
			padding-top: constant(safe-area-inset-top);

		}

	}

	@supports(bottom:env(safe-area-inset-top)) {

		// 如果存在底部安全区域
		.header {
			padding-top: env(safe-area-inset-top);

		}

	}
	.tianjia {
		width: 11.25rem;
		height: 11.25rem;
		border-radius: 0.625rem;
		margin: 0 auto;
		background: #ffffff;
		margin-top: 5.625rem;

		.code {
			display: block;
			width: 100%;
			height: 100%;
		}
	}

	.button {
		width: 15rem;
		height: 2.75rem;
		background: linear-gradient(90deg,
			rgba(66, 155, 255, 1) 0%,
			rgba(121, 80, 254, 1) 100%);
		border-radius: 1.25rem;
		margin: 0 auto;
		margin-top: 3.125rem;
		text-align: center;
		font-size: 1.125rem;
		font-weight: 500;
		color: rgba(255, 255, 255, 1);
		line-height: 2.75rem;
	}
</style>
